home *** CD-ROM | disk | FTP | other *** search
- Path: ornews.intel.com!news
- From: thurman_b_miller@ccm2.hf.intel.com (Thurman Miller)
- Newsgroups: comp.lang.c++
- Subject: Conversion routines needed
- Date: Mon, 29 Jan 1996 18:26:58 GMT
- Organization: Intel Corporation
- Message-ID: <4ej3j9$49d@ornews.intel.com>
- NNTP-Posting-Host: thurman-pc.co.intel.com
- X-Newsreader: Forte Free Agent 1.0.82
-
- I'm fairly new to C++. I'm confident in how classes work and have had
- fun using this new approach. However, I came into this with about zero
- experience in C, so I'm having loads of problems trying to convert
- something to another thing.
-
- My ultimate goal is for someone to recommend a great book or a good
- chapter in a worthless book, or somewhere inbetween. Saying that, here
- are some specific examples that have given me grief over the past
- week:
-
- I'm trying to interface into a 3rd party product. Their definitions
- are as follows:
-
- typedef unsigned char RFC_CHAR;
- typedef RFC_CHAR SAP_MATNR[18];
- typedef RFC_CHAR SAP_PLANT[4];
-
-
- Now, I've got (Using MS Visual C++)
-
- CString material;
- int nChars = GetDlgItemText(IDC_MATERIAL, material.GetBuffer(18),18);
- static SAP_MATNR sap_mat;
- // For some reason, material.GetLength() was returning zero.
- memcpy( sap_mat, material, nChars);
-
- CString plantname;
- int nIndex = m_cboPlant.GetCurSel();
- m_cboPlant.GetLBText(nIndex,plantname);
-
- static SAP_PLANT sap_plant;
- // Why GetLength worked here and not above, I've no idea.
- memcpy( sap_plant, plantname, plantname.GetLength() );
-
-
- I need to make the following call:
-
- int z_getmat
- (RFC_HANDLE hRfc,
- SAP_MATNR * pMatnbr,
- SAP_PLANT * pPlntno,
- ITAB_H hMarcTable,
- char * pException
- );
-
- so I used the following:
-
- int nRet = z_getmat(hRfc,&sap_mat,&sap_plant,phMarcTable,errorstr);
-
-
- In all honesty, I did this by blindly trying about 100 different
- things and I'm at a point to where the whole contraption works, but
- I've more or less lost my way as to how I got here.
-
- A couple of questions:
-
- 1. I mistakenly assumed that:
-
- RFC_CHAR SAP_MATNR[18] is the same as
- typedef RFC_CHAR SAP_MATNR[18]
-
- Why aren't these equivalent?
-
- 2. An unsigned char, is apparently a integer value from 0-255, so why
- doesn't the following type-cast work?
-
- CString sap_mat = (CString)SAP_MATNR;
-
- 3. Memcpy seems so "Cish". Is there a better way to convert?
-
- 4. Why does a "&sap_plant" = "* sap_plant"
-
-
- Any help appreciated!
-
- Thurman Miller
-
-
-
-
-
-
-